package com.qing.demo01.controller;

import com.qing.demo01.entity.UserInfo;
import com.qing.demo01.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@RequestMapping("/user")
@Controller
public class UserController {


	//@Qualifier("userServiceImpl")
	@Autowired
	private UserService userService;


	@GetMapping("/all")
	public String findAll(Model model) {
		model.addAttribute("users", userService.selectAll());
		return "hello";
	}

	@PostMapping
	@ResponseBody
	public void add(@RequestBody UserInfo userInfo) {
		userService.add(userInfo);
	}
}
